home *** CD-ROM | disk | FTP | other *** search
-
- package sub_arctic.constraints;
-
- import sub_arctic.lib.interactor_consts;
-
- /**
- * Interface to define standard constraint encoding constants.
- * <b>Important note</b>: you don't normally need to know or use these internal
- * encodings. Instead you can use the std_constraint_consts interface and
- * std_function class which hides all the internals behind a nicer API.<p>
- *
- * Constraints with 0, 1, 2, or 3 operands are supported. Operands
- * (depended upon object parts) are encoded in 6 bits with a code indicating
- * which object in the upper 3 bits and a part code in the lower 3.
- * Objects that can be depended upon include: self, parent, previous sibling,
- * next sibling, first child, last child, min child, and max child. Parts of
- * those objects that can be depended upon include: x, y, x2 (right), y2
- * (bottom), w, h, horizontal center, vertical center, visible, enabled,
- * part_a (object specific), and part_b (object specific).<p>
- *
- * Constraints are internally encoded as follows:
- * <pre>
- * 8 6 6 6 5
- * KKKKKKKK AAAAAA BBBBBB CCCCCC 0 00000 clip(A, B+K, C-K)
- * KKKKKKKK AAAAAA BBBBBB CCCCCC 1 00000 wrap(A, B+K, C-K)
- * [K is 8 bit unsigned]
- *
- * 16 6 5 5
- * KKKKKKKKKKKKKKKK XXXXXX 00000 00001 64 0 operand operations
- * [K is 16 bit signed]
- * 16 6 5 5
- * KKKKKKKKKKKKKKKK AAAAAA 00001 00001 31 1 operand operations
- * ... [K is 16 bit signed]
- * KKKKKKKKKKKKKKKK AAAAAA 11111 00001
- *
- * 15 6 6 5
- * KKKKKKKKKKKKKKK AAAAAA BBBBBB 00010 30 2 operand operations
- * ... [K is 15 bit signed]
- * KKKKKKKKKKKKKKK AAAAAA BBBBBB 11111
- * </pre>
- * Where KKK represents a constant, AAA, BBB, and CCC represent parameter
- * objects, and XXX represents bits used to encode an op code.<p>
- *
- * @author Scott Hudson
- */
-
- public interface std_encoding_consts {
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
- /* Orientation codes for horizontal vs. vertical vs. other. These are
- * used to tag constraint objects for type checking (since we disallow
- * mixed orientation encodings in lightweight constraints). These
- * constants are suitable for use as bits in a set.
- */
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Orientation code indicating horizontal constraint. */
- public static final int HORIZONTAL = 0x1;
-
- /** Orientation code indicating vertical constraint. */
- public static final int VERTICAL = 0x2;
-
- /** Orientation code indicating constraint that is neither horizontal or
- * vertical in nature. */
- public static final int NOT_ORIENTED = 0x4;
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
- /* Integer encoding for object parts. An object part encoding is placed
- * 6 bits with the high order 3 bits providing an object designator
- * and the lower 3 bit holding a part designator. Normally, this integer
- * encoding is not used directly in "user code". Instead use SELF.x(),
- * etc. defined in std_constraint_consts. */
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Code to reference local neighborhood object: self */
- public static final int OBJCODE_SELF = 0;
-
- /** Code to reference local neighborhood object: parent */
- public static final int OBJCODE_PARENT = 1;
-
- /** Code to reference local neighborhood object: first child */
- public static final int OBJCODE_FIRST_CHILD = 2;
-
- /** Code to reference local neighborhood object: last child */
- public static final int OBJCODE_LAST_CHILD = 3;
-
- /** Code to compute the maximum of some part among child objects */
- public static final int OBJCODE_MAX_CHILD = 4;
-
- /** Code to compute the minimum of some part among child objects */
- public static final int OBJCODE_MIN_CHILD = 5;
-
- /** Code to reference local neighborhood object: previous sibling */
- public static final int OBJCODE_PREV_SIBLING = 6;
-
- /** Code to reference local neighborhood object: next sibling */
- public static final int OBJCODE_NEXT_SIBLING = 7;
-
- /** Largest valid object code. */
- public static final int OBJCODE_MAX = OBJCODE_NEXT_SIBLING;
-
- /** Mask for accessing object code in object/part encoding. Object is
- * accessed as (enc >> OBJCODE_SHIFT) & OBJCODE_MASK. */
- public static final int OBJCODE_MASK = 0x7;
-
- /** Shift value for accessing object code in object/part encoding. Object is
- * accessed as (enc >> OBJCODE_SHIFT) & OBJCODE_MASK. */
- public static final int OBJCODE_SHIFT = 3;
-
- /** Special object code to designate some child object during mark
- * out-of-date phase. This in not used in encoding of constraints. */
- public static final int OBJCODE_SOME_CHILD = OBJCODE_MAX + 1;
-
- /** Table of strings for object code names. */
- public static final String[] OBJCODE_strings = {
- "SELF", "PARENT", "FIRST_CHILD", "LAST_CHILD", "MAX_CHILD", "MIN_CHILD",
- "PREV_SIBLING", "NEXT_SIBLING", "SOME_CHILD" };
-
- /** Table of very terse strings for object code names. */
- public static final String[] OBJCODE_tags = {
- "S", "P", "FC", "LC", "XC", "NC", "PS", "NS", "*C" };
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Code to reference the x or y part of an object. */
- public static final int PARTCODE_XY = 0;
-
- /** Code to reference the x2 or y2 part of an object (which is x+w or y+h). */
- public static final int PARTCODE_XY2 = 1;
-
- /** Code to reference the w or h part of an object */
- public static final int PARTCODE_WH = 2;
-
- /** Code to reference the horizontal or vertical center of an object (which
- * is x+w/2 or y+h/2). */
- public static final int PARTCODE_CENTER = 3;
-
- /** Code to reference the visible part of an object */
- public static final int PARTCODE_VISIBLE = 4;
-
- /** Code to reference the enabled part of an object */
- public static final int PARTCODE_ENABLED = 5;
-
- /** Code to reference the part_a part of an object */
- public static final int PARTCODE_PART_A = 6;
-
- /** Code to reference the part_b part of an object */
- public static final int PARTCODE_PART_B = 7;
-
- /** Largest valid part code */
- public static final int PARTCODE_MAX = PARTCODE_PART_B;
-
- /** Mask to extract part code from object/part encoding. The part is found
- * using (enc>>PARTCODE_SHIFT) & PARTCODE_MASK. */
- public static final int PARTCODE_MASK = 0x7;
-
- /** Shift value to extract part code from object/part encoding. The part is
- * found using (enc>>PARTCODE_SHIFT) & PARTCODE_MASK. */
- public static final int PARTCODE_SHIFT = 0;
-
- /** Table of strings for horizontal part names. */
- public static final String[] PARTCODE_strings_h = {
- "X", "X2", "W", "CENTER", "VISIBLE", "ENABLED", "PART_A", "PART_B" };
-
- /** Table of strings for vertical part names. */
- public static final String[] PARTCODE_strings_v = {
- "Y", "Y2", "H", "CENTER", "VISIBLE", "ENABLED", "PART_A", "PART_B" };
-
- /** Table of very terse strings for horizontal part names. */
- public static final String[] PARTCODE_tags_h = {
- "X", "X2", "W", "C", "V", "E", "PA", "PB" };
-
- /** Table of very terse strings for vertical part names. */
- public static final String[] PARTCODE_tags_v = {
- "Y", "Y2", "H", "C", "V", "E", "PA", "PB" };
-
- /** Mask to limit an encode to just the low order 6 bits (for an object/part
- * encoding. */
- public static final int OBJPART_MASK = 0x3f;
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /*---------------------------------------------------------------------*/
- /* Constraints of various flavors are encoded as follows:
- *
- * 8 6 6 6 5
- * KKKKKKKK AAAAAA BBBBBB CCCCCC 0 00000 clip(A, B+K, C-K)
- * KKKKKKKK AAAAAA BBBBBB CCCCCC 1 00000 wrap(A, B+K, C-K)
- * [K is 8 bit unsigned]
- *
- * 16 6 5 5
- * KKKKKKKKKKKKKKKK XXXXXX 00000 00001 64 0 operand operations
- * [K is 16 bit signed]
- * 16 6 5 5
- * KKKKKKKKKKKKKKKK AAAAAA 00001 00001 31 1 operand operations
- * ... [K is 16 bit signed]
- * KKKKKKKKKKKKKKKK AAAAAA 11111 00001
- *
- * 15 6 6 5
- * KKKKKKKKKKKKKKK AAAAAA BBBBBB 00010 30 2 operand operations
- * ... [K is 15 bit signed]
- * KKKKKKKKKKKKKKK AAAAAA BBBBBB 11111
- */
- /*---------------------------------------------------------------------*/
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
- /* 1-bit codes for selecting 3 operand ops<p>
- *
- * 3 ops are encoded as:<br>
- * <pre>
- * 8 6 6 6 1 5
- * KKKKKKKK AAAAAA BBBBBB CCCCCC X 00000
- * </pre>
- */
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Shift value for extracting op codes from 3-op constraints. An op code
- * of this type can be accessed via: (enc & OP3_MASK) >> OP3_SHIFT. */
- public static final int OP3_SHIFT = 5;
-
- /** Mask value for extracting op codes from 3-op constraints. An op code
- * of this type can be accessed via: (enc & OP3_MASK) >> OP3_SHIFT. */
- public static final int OP3_MASK = 0x20;
-
- /** Fixed low order bits for 3-op constraint encoding. */
- public static final int OP3_LOBITS= 0x00;
-
- /** Lowest valid 3-op op code */
- public static final int OP3_MIN = 0;
-
- /** Op code for clip(A, B+K, C-K) */
- public static final int OP_clip = 0; // clip(A, B+K, C-K) [same 8 bit K]
- /** Op code for wrap(A, B+K, C-K) */
- public static final int OP_wrap = 1; // wrap(A, B+K, C-K)
-
- /** Highest valid 3-op op code */
- public static final int OP3_MAX = 1;
-
- /** Table of op code name strings */
- public static final String[] OP3_strings = {"clip", "wrap"};
-
- /** Table of terse op code name strings */
- public static final String[] OP3_tags = {"clip", "wrap"};
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
- /* 6-bit codes for selecting 0 operand ops<p>
- *
- * 0 ops are encoded as:<br>
- * <pre>
- * 16 6 5 5
- * KKKKKKKKKKKKKKKK XXXXXX 00000 00001 64 0 operand operations
- * </pre>
- */
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Shift value for extracting op codes from 0-op constraints. An op code
- * of this type can be accessed via: (enc & OP0_MASK) >> OP0_SHIFT. */
- public static final int OP0_SHIFT = 10;
-
- /** Mask value for extracting op codes from 0-op constraints. An op code
- * of this type can be accessed via: (enc & OP0_MASK) >> OP0_SHIFT. */
- public static final int OP0_MASK = 0xf400;
-
- /** Fixed low order bits for 0-op constraint encoding. */
- public static final int OP0_LOBITS= 0x001;
-
- /** Lowest valid 0-op op code */
- public static final int OP0_MIN = 0;
-
- /** Special op code that indicates that no constraint should be applied */
- public static final int OP_NONE = 0; // no constraint
-
- /** Op code that indicates a separate external (or heavyweight) constraint
- * is being applied. */
- public static final int OP_external = 1; // ext constraint
-
- /** Op code for a constant constraint */
- public static final int OP_konst = 2; // constant K
- // ops 3..63 TBD
-
- /** Largest valid 0-op op code */
- public static final int OP0_MAX = 2;
-
- /** Table of strings for 0-op op code names */
- public static final String[] OP0_strings = {"NONE", "external", "const"};
-
- /** Table of terse strings for 0-op op code names */
- public static final String[] OP0_tags = {"NONE", "ext", "cnst"};
-
- /** Mask for testing none. Test is "(enc & NONE_TEST_MASK)==NONE_TEST_VAL" */
- public static final int NONE_TEST_MASK = 0xffff;
-
- /** Value for testing none. Test is "(enc & NONE_TEST_MASK)==NONE_TEST_VAL" */
- public static final int NONE_TEST_VAL =
- (OP_NONE << OP0_SHIFT) & OP0_MASK | OP0_LOBITS;
-
- /** Mask for testing external. Test is
- * "(enc & EXTERNAL_TEST_MASK) == EXTERNAL_TEST_VAL */
- public static final int EXTERNAL_TEST_MASK = 0xffff;
-
- /** Value for testing external. Test is
- * "(enc & EXTERNAL_TEST_MASK) == EXTERNAL_TEST_VAL" */
- public static final int EXTERNAL_TEST_VAL =
- (OP_external << OP0_SHIFT) & OP0_MASK | OP0_LOBITS;
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
- /* 5-bit codes for selecting 1 operand ops<p>
- *
- * 1 ops are encoded as:<br>
- * <pre>
- * 16 6 5 5
- * KKKKKKKKKKKKKKKK AAAAAA 00001 00001 31 1 operand operations
- * ... [K is 16 bit signed]
- * KKKKKKKKKKKKKKKK AAAAAA 11111 00001
- * </pre>
- */
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Shift value for extracting op codes from 1-op constraints. An op code
- * of this type can be accessed via: (enc & OP1_MASK) >> OP1_SHIFT. */
- public static final int OP1_SHIFT = 5;
-
- /** Mask value for extracting op codes from 1-op constraints. An op code
- * of this type can be accessed via: (enc & OP1_MASK) >> OP1_SHIFT. */
- public static final int OP1_MASK = 0x3e0;
-
- /** Fixed low order bits for 1-op constraint encoding. */
- public static final int OP1_LOBITS= 0x01;
-
- /** Lowest valid 1-op op code */
- public static final int OP1_MIN = 1;
-
- /** Op code for self.fun1(A,K) */
- public static final int OP_self_fun1 = 1; // self.fun1(A,K)
-
- /** Op code for parent.fun1(A,K) */
- public static final int OP_parent_fun1 = 2; // parent.fun1(A,K)
-
- /** Op code for ~A & (K|0xffff0000) */
- public static final int OP_not_mask = 3; // ~A & (K|0xffff0000)
-
- /** Op code for A & (K|0xffff0000) */
- public static final int OP_mask = 4; // A & (K|0xffff0000)
-
- /** Op code for (A-self.wh)/2 + K */
- public static final int OP_centered = 5; // (A-self.wh)/2 + K
-
- /** Op code for A + K */
- public static final int OP_offset = 6; // A + K
-
- /** Op code for A - self.wh - K */
- public static final int OP_far_edge_just= 7; // A - self.wh - K
- // ops 8..31 TBD
-
- /** Largest valid 1-op op code */
- public static final int OP1_MAX = 7;
-
- /** Table of op code name strings */
- public static final String[] OP1_strings = {
- "self.fun1", "parent.fun1", "not_mask", "mask", "centered", "offset",
- "far_edge_just"};
-
- /** Table of terse op code name strings */
- public static final String[] OP1_tags = {
- "s.f1", "p.f1", "ntmsk", "msk", "cent", "off", "fej"};
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
- /* 5 bit codes for selecting 2 operand ops<p>
- * <pre>
- * 15 6 6 5
- * KKKKKKKKKKKKKKK AAAAAA BBBBBB 00010 30 2 operand operations
- * ... [K is 15 bit signed]
- * KKKKKKKKKKKKKKK AAAAAA BBBBBB 11111
- * </pre>
- */
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Shift value for extracting op codes from 2-op constraints. An op code
- * of this type can be accessed via: (enc & OP2_MASK) >> OP2_SHIFT. */
- public static final int OP2_SHIFT = 0;
-
- /** Mask value for extracting op codes from 2-op constraints. An op code
- * of this type can be accessed via: (enc & OP2_MASK) >> OP2_SHIFT. */
- public static final int OP2_MASK = 0x1f;
-
- /** Fixed low order bits for 2-op constraint encoding. */
- public static final int OP2_LOBITS= 0;
-
- /** Lowest valid 2-op op code */
- public static final int OP2_MIN = 2;
-
- /** Op code for A + B + K */
- public static final int OP_add = 2; // A + B + K
-
- /** Op code for A - B + K */
- public static final int OP_subtract = 3; // A - B + K
-
- /** Op code for A * B + K */
- public static final int OP_mult = 4; // A * B + K
-
- /** Op code for A / B + K */
- public static final int OP_div = 5; // A / B + K
-
- /** Op code for A % B + K */
- public static final int OP_mod = 6; // A % B + K
-
- /** Op code for A & B & (K | 0xffff8000) */
- public static final int OP_and = 7; // A & B & (K | 0xffff8000)
-
- /** Op code for (A | B) & (K | 0xffff8000) */
- public static final int OP_or = 8; // (A | B) & (K | 0xffff8000)
-
- /** Op code for A ^ B) & (K | 0xffff8000) */
- public static final int OP_xor = 9; // (A ^ B) & (K | 0xffff8000)
-
- /** Op code for min(A, B) + K */
- public static final int OP_min = 10; // min(A, B) + K
-
- /** Op code for max(A, B) + K */
- public static final int OP_max = 11; // max(A, B) + K
-
- /** Op code for (A + B)/2 + K */
- public static final int OP_ave = 12; // (A + B)/2 + K
-
- /** Op code for rotate_x(theta, B)+K */
- public static final int OP_rotx = 13; // rotate_x(theta, B)+K
-
- /** Op code for rotate_y(theta, B)+K */
- public static final int OP_roty = 14; // rotate_y(theta, B)+K
-
- /** Op code for (if enabled then A else B) + K */
- public static final int OP_if_enabled = 15; // (if enabled then A else B) + K
-
- /** Op code for (if visible then A else B) + K */
- public static final int OP_if_visible = 16; // (if visible then A else B) + K
-
- /** Op code for self.fun2(A, B, K) */
- public static final int OP_self_fun2 = 17; // self.fun2(A, B, K)
-
- /** Op code for parent.fun2(A, B, K) */
- public static final int OP_parent_fun2 = 18; // parent.fun2(A, B, K)
-
- /** Op code for B - A - K */
- public static final int OP_fill = 19; // B - A - K
-
- // ops 20..31 TBD
-
- /** The largest valid 2-op op code */
- public static final int OP2_MAX = 19;
-
- /** Table of op code name strings. */
- public static final String[] OP2_strings = {
- "add", "subtract", "mult", "div", "mod", "and", "or", "xor", "min", "max",
- "ave", "rotx", "roty", "if_enabled", "if_visible", "self.fun2",
- "parent.fun2", "fill"};
-
- /** Table of terse op code name strings. */
- public static final String[] OP2_tags = {
- "add", "sub", "mul", "div", "mod", "and", "or", "xor", "min", "max",
- "ave", "rotx", "roty", "ifen", "ifvis", "s.f2", "p.f2", "fil"};
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
- }
-
- /*=========================== COPYRIGHT NOTICE ===========================
-
- This file is part of the subArctic user interface toolkit.
-
- Copyright (c) 1996 Scott Hudson and Ian Smith
- All rights reserved.
-
- The subArctic system is freely available for most uses under the terms
- and conditions described in
- http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html
- and appearing in full in the lib/interactor.java source file.
-
- The current release and additional information about this software can be
- found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
-
- ========================================================================*/
-